﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VoucherOutReturnDetail.aspx.cs"
    Inherits="SalesManagement.Modules.Purchase.VoucherOutReturnDetail" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Phiếu xuất kho trả lại</title>
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
        .total-field
        {
            background-color: #fff;
            font-weight: bold !important;
            color: #000;
            border: solid 1px silver;
            padding: 2px;
            margin-right: 5px;
            text-align: right;
        }
    </style>

    <script src="../../Javascript/Global.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
    function DocumentReady() {
        ProviderSelect();
    }
    function ProviderSelect() {        
        stVoucherIn.proxy.setUrl('../List/SearProduct.ashx?type=VoucherIn&pro=' + cbProvider.getValue())
    }
    function SelectVoucherIn() {      
        var vcId = cbVoucherIn.getValue();
        DirectMethod.getDetailVoucherIn(vcId, {
        success: function() {
        stVoucherOutReturn.removeAll();
            }
        });
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="DirectMethod">
        <Listeners>
        <DocumentReady Handler="DocumentReady();" Delay="10" />         
        </Listeners>
    </ext:ResourceManager>
    <ext:Store runat="server" ID="stProvider">
        <Reader>
            <ext:JsonReader IDProperty="ObjectId">
                <Fields>
                    <ext:RecordField Name="ObjectId">
                    </ext:RecordField>
                    <ext:RecordField Name="ObjectName">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="RowLayout">
        <Items>
            <ext:Toolbar ID="Toolbar1" runat="server">
                <Items>
                    <ext:Button ID="btnNew" runat="server" Icon="PageAdd" Text="Tạo mới">
                    </ext:Button>
                    <ext:Button ID="Button3" runat="server" Icon="Disk" Text="Lưu" Disabled="true">
                    </ext:Button>
                    <ext:Button ID="btnCancel" runat="server" Icon="Cancel" Text="Bỏ qua">
                    </ext:Button>
                    <ext:Button ID="btnDelete" runat="server" Icon="Delete" Text="Xóa">
                    </ext:Button>
                    <ext:Button ID="btnPrinter" runat="server" Text="In" Icon="Printer" Disabled="false">
                    </ext:Button>
                </Items>
            </ext:Toolbar>
            <ext:Panel ID="Panel2" runat="server" Frame="true" Height="145" Layout="FormLayout"
                LabelWidth="90">
                <Items>
                    <ext:Panel ID="pnlFlexEven" runat="server" Layout="HBoxLayout" LabelWidth="60" AnchorHorizontal="100%">
                        <Defaults>
                            <ext:Parameter Name="margins" Value="0 5 0 0" Mode="Value" />
                        </Defaults>
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Padding="2" Align="Middle" />
                        </LayoutConfig>
                        <Items>
                            <ext:TextField ID="TextField2" runat="server" FieldLabel="Số phiếu" Flex="1" LabelWidth="90" />
                            <ext:DateField ID="DateField1" runat="server" FieldLabel="Ngày (*)" Flex="1" />
                              <ext:ComboBox ID="ComboBox1" runat="server" TriggerAction="All" FieldLabel="Nhân viên"
                                Flex="2">
                                <Items>
                                    <ext:ListItem Text="Nguyễn Văn A" Value="hcm" />
                                    <ext:ListItem Text="Nguyễn Văn B" Value="hn" />
                                </Items>
                                <SelectedItem Value="hcm" />
                            </ext:ComboBox>
                        </Items>
                    </ext:Panel>
              
                    <ext:Panel ID="Panel3" runat="server" Layout="HBoxLayout" LabelWidth="40" AnchorHorizontal="100%">
                        <Defaults>
                            <ext:Parameter Name="margins" Value="0 5 0 0" Mode="Value" />
                        </Defaults>
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Padding="2" Align="Middle" />
                        </LayoutConfig>
                        <Items>
                            <ext:ComboBox ID="cbProvider" runat="server" FieldLabel="Nhà cung cấp" Editable="false"
                                StoreID="stProvider" DisplayField="ObjectName" ValueField="ObjectId" TriggerAction="All"
                                Flex="1" LabelWidth="90">
                                <Listeners>
                                <Select Handler="ProviderSelect()" />
                                </Listeners>
                              <%--  <DirectEvents>
                                    <Select OnEvent="ProviderChange">
                                    </Select>
                                </DirectEvents>--%>
                            </ext:ComboBox>
                            <ext:TextField ID="txtMST" runat="server" FieldLabel="MST" Flex="1" />
                        </Items>
                    </ext:Panel>
                    <ext:Panel ID="Panel5" runat="server" Layout="HBoxLayout" LabelWidth="60" AnchorHorizontal="100%">
                        <Defaults>
                            <ext:Parameter Name="margins" Value="0 5 0 0" Mode="Value" />
                        </Defaults>
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Padding="2" Align="Middle" />
                        </LayoutConfig>
                        <Items>
                            <ext:TextField ID="TextField5" runat="server" FieldLabel="Địa chỉ" Flex="1" LabelWidth="90" />
                        </Items>
                    </ext:Panel>
                    <ext:Panel ID="Panel6" runat="server" Layout="HBoxLayout" LabelWidth="60" AnchorHorizontal="100%">
                        <Defaults>
                            <ext:Parameter Name="margins" Value="0 5 0 0" Mode="Value" />
                        </Defaults>
                        <LayoutConfig>
                            <ext:HBoxLayoutConfig Padding="2" Align="Middle" />
                        </LayoutConfig>
                        <Items>
                            <ext:ComboBox ID="cbVoucherIn" runat="server" DisplayField="VoucherInNo" ValueField="VoucherInId"
                                TypeAhead="false" LoadingText="Searching..." PageSize="50" ItemSelector="div.search-item"
                                MinChars="1" FieldLabel="Chứng từ nhập" LabelWidth="90" Width="350">
                            <Listeners>
                                        <Select Fn="SelectVoucherIn" />
                                    </Listeners>
                                <Store>
                                    <ext:Store ID="stVoucherIn" runat="server" AutoLoad="false">
                                        <Proxy>
                                            <ext:HttpProxy Method="POST" Url="../List/SearProduct.ashx?type=VoucherIn" />
                                        </Proxy>
                                        <Reader>
                                            <ext:JsonReader Root="SearProduct" TotalProperty="total">
                                                <Fields>
                                                    <ext:RecordField Name="VoucherInId" />
                                                    <ext:RecordField Name="VoucherInNo" />
                                                    <ext:RecordField Name="VocherInDate" />
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>
                                    </ext:Store>
                                </Store>
                                <Template ID="Template1" runat="server">
                                    <Html>
                                    <tpl for=".">                                        
						                  <div class="search-item">
							               {VoucherInNo}
						                  </div>
					                   </tpl>
                                    </Html>
                                </Template>
                            </ext:ComboBox>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Panel>
            <ext:Panel runat="server" ID="pnCentel" Layout="ColumnLayout"   RowHeight="1">
            <Items>
            <ext:GridPanel ID="grVoucherDetailIn" runat="server" AutoExpandColumn="ProductName" Border="false"
              ColumnWidth="0.4" ColumnLines="true" >
                <Store>
                    <ext:Store ID="stVoucherDetailIn" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="VoucherInDetailId">
                                <Fields>
                                    <ext:RecordField Name="VoucherInDetailId" />
                                    <ext:RecordField Name="ProductId" />                                  
                                    <ext:RecordField Name="ProductName" />                                   
                                    <ext:RecordField Name="Quantity" />
                                     <ext:RecordField Name="UnitName" />
                                    <ext:RecordField Name="UnitPrice" />                                   
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel2" runat="server">
                    <Columns>               
                        <ext:Column ColumnID="ProductName" DataIndex="ProductName" Header="Tên hàng" />
                        <ext:Column DataIndex="Quantity" Header="Số lượng" />                      
                        <ext:Column DataIndex="UnitName" Header="Đơn vị tính" />
                    </Columns>
                </ColumnModel>  
                <SelectionModel>
                <ext:RowSelectionModel SingleSelect="true">                
                </ext:RowSelectionModel>
                </SelectionModel>
               <%-- <Listeners>
                <%--<DblClick Handler=""--%>
                </Listeners>--%>
            </ext:GridPanel>
              <ext:GridPanel ID="grVoucherOutReturn" runat="server" AutoExpandColumn="ProductName" Border="false"
              ColumnWidth="0.6" ColumnLines="true" >
                <Store>
                    <ext:Store ID="stVoucherOutReturn" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="VoucherInDetailId">
                                <Fields>
                                    <ext:RecordField Name="VoucherInDetailId" />
                                    <ext:RecordField Name="ProductId" />                                  
                                    <ext:RecordField Name="ProductName" />                                   
                                    <ext:RecordField Name="Quantity" />
                                     <ext:RecordField Name="UnitName" />
                                    <ext:RecordField Name="UnitPrice" />                                   
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>               
                        <ext:Column ColumnID="ProductName" DataIndex="ProductName" Header="Tên hàng" />
                        <ext:Column DataIndex="UnitName" Header="Đơn vị tính" />
                        <ext:Column DataIndex="Quantity" Header="Số lượng" />                      
                        <ext:Column DataIndex="Quantity" Header="Số lượng" />   
                    </Columns>
                </ColumnModel>  
            </ext:GridPanel>
            </Items>
            </ext:Panel>
        </Items>
    </ext:Viewport>
    </form>
</body>
</html>
